package com.example.maxboxtwo;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.widget.ImageView;

import com.example.maxboxtwo.components.fragments.Onefragment;
import com.example.maxboxtwo.components.fragments.TwoFragment;
import com.example.maxboxtwo.utils.adapters.CustomizeViewPageAdapter;
import com.example.maxboxtwo.utils.listeners.FragmentPageChangeListener;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    public static Context context;
    private ViewPager viewPage;
    private ImageView dark,light;
    private List<Fragment> fragments;
    private CustomizeViewPageAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        this.context = getApplicationContext();
        initialize();
        // when changing the page,at same time,you should change two icon
        viewPage.addOnPageChangeListener(new FragmentPageChangeListener(dark,light));
        adapter =  new CustomizeViewPageAdapter(getSupportFragmentManager(),fragments);
        viewPage.setAdapter(adapter);
        viewPage.setCurrentItem(0);
    }


    public void initialize(){
        fragments = new ArrayList<Fragment>();
        fragments.add(new Onefragment());
        fragments.add(new TwoFragment());

        viewPage = findViewById(R.id.viewPage);
        dark = findViewById(R.id.left);
        light = findViewById(R.id.right);
    }
}
